package com.sud.modules.system.controller;

import com.sud.config.persistence.Page;
import com.sud.config.util.Result;
import com.sud.modules.system.model.User;
import com.sud.modules.system.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 功能：
 * 作者：SUD
 * 时间：2020/9/4 14:05
 */
@Api(tags = "测试类")
@RestController
public class TestController {
    @Resource
    private UserService userService;

    @ApiOperation(value="测试方法",produces="application/json",httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name="user",value="查询参数",required=false,dataType="User",paramType="query"),
            @ApiImplicitParam(name="pageNo",value="当前页码",required=false,dataType="Integer",paramType="query"),
            @ApiImplicitParam(name="pageSize",value="页大小",required=false,dataType="Integer",paramType="query"),
            @ApiImplicitParam(name="orderBy",value="排序字段",required=false,dataType="String",paramType="query")
    })
    @RequestMapping(value = "/findPageUser",method = RequestMethod.GET)
    public Result<Page<User>> findPageUser(User user,Integer pageNo,Integer pageSize,String orderBy, HttpServletRequest request){
        Page<User> page = userService.pageUser(new Page<User>(request),user);
        return Result.data(page);
    }
}

